classdef FeatureSubsetSizeable < BatHandle
    %FEATURESUBSETSIZEABLE Summary of this class goes here
    %   Detailed explanation goes here
    
    properties ( SetAccess = protected )
        featureSubsetSize = 1 - eps
        nFeatureSubsetSampling = 100
    end
    
    methods
        function [  ] = setFeatureSubsetSize( this, featureSubsetSize )
            if nargin == 1
                this.featureSubsetSize = 1 - eps;
            end
            if nargin == 2
                this.featureSubsetSize = featureSubsetSize;
            end
        end
        
        function [  ] = setNFeatureSubsetSampling( this, nFeatureSubsetSampling )
            if nargin == 1
                this.nFeatureSubsetSampling = 100;
            end
            if nargin == 2
                this.nFeatureSubsetSampling = nFeatureSubsetSampling;
            end
        end
    end
    
    methods
        function [ this ] = FeatureSubsetSizeable(  )
        end
    end
    
    methods
        function [ kFeature ] = calcFeatureSubsetSizeOn( this, X )
            nFeature = size(X, 2);
            if this.featureSubsetSize >= 1
                kFeature = min(nFeature, this.featureSubsetSize);
            else
                kFeature = ceil(nFeature*this.featureSubsetSize);
            end
        end
        
        function [ zSubsetSize ] = calcFeatureSubsetSamplingSizeOn( this, X )
            % Calculate feature subset sampling size
            % Evenly devide the original feature subset into 100 devisions
            
            nFeature = size(X, 2);
            
            if nFeature <= this.nFeatureSubsetSampling
                zSubsetSize = 1:nFeature;
            else
                zSubsetSize = linspace(1, nFeature, this.nFeatureSubsetSampling);
                zSubsetSize = ceil(zSubsetSize);
            end
        end
    end
end

